export const search={
    state: {
        history:[],
        goods:[]
    },
    mutations: {
        setHistory:(state,single)=>{
            let index=state.history.findIndex(item=>item==single)
            if(index==-1){
            state.history.unshift(single)
            }else{
                state.history.splice(index,1)
            state.history.unshift(single)
            }
            // console.log(state.history);
        },
        delSingle:(state,id)=>{
            console.log(id);
            state.history.splice(id,1)
            console.log(state.history);
        },
        // setGoods:(state,goods)=>{
        //     state.goods=goods
        //     console.log(state.goods);
        // }
    },
    actions: {
        SETHISTORY:({commit},single)=>{
            commit('setHistory',single)
        },
        DELSINGLE:({commit},id)=>{
            commit('delSingle',id)
        },
        // SETGOODS:({commit},goods)=>{
        //     commit('setGoods',goods)
        // }

    }
}